﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Domain.Model;

namespace MvcApplication1.Controllers
{
    public class ResourceController : Controller
    {
        private ViewsModel.ResourceViewModel resourceViewModel = new ViewsModel.ResourceViewModel();

        public ActionResult Index()
        {
            var resources = resourceViewModel.GetResources();
            return View(resources);
        }

        public ActionResult AddResource()
        {
            return View();
        }

        [HttpPost]
        public ActionResult AddResource(Resource resource)
        {
            if (ModelState.IsValid)
            {
                resourceViewModel.AddResource(resource);
                return RedirectToAction("Index");
            }

            return View(resource);
        }

    }
}
